package com.china08.yxyapi.repository.mg.huixue;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;

import com.china08.yxyapi.entity.mg.huixue.YxyHuixuePlan;

public interface YxyHuixuePlanRepository extends MongoRepository<YxyHuixuePlan, String> {

    // 根据状态信息&结束时间获取列表
    List<YxyHuixuePlan> findByStatusAndEndDateLessThan(Integer status, Integer endDate);

    // 获取正在进行的计划列表
    List<YxyHuixuePlan> findByStatus(Integer status);

    /**
     * 根据学生id和学习计划的状态和当前分数值查询相关记录
     * 
     * @param studentId
     *            学生id
     * @param status
     *            学习计划的状态
     * @param currentScore
     *            当前分数值
     * @param pageable
     *            翻页
     * @return
     */
    Page<YxyHuixuePlan> findByStudentIdAndStatusAndCurrentScoreLessThan(String studentId, Integer status,
            Integer currentScore, Pageable pageable);

    /**
     * 根据主键id来查询相关记录
     * 
     * @param planId
     * @return
     */
    YxyHuixuePlan findById(String planId);

    Page<YxyHuixuePlan> findByStudentIdAndStatusAndCurrentScoreGreaterThan(String studentId, Integer status,
            Integer currentScore, Pageable pageable);

    /**
     * 根据学生id和成绩获取学习计划列表,最近创建的排上面(成绩为-1d,则为计划列表)
     *
     * @param currentScore
     *            the current score
     * @param pageable
     *            the pageable
     * @return the page< yxy huixue plan>
     */
    Page<YxyHuixuePlan> findByStudentIdAndCurrentScore(String studentId, Double currentScore, Pageable pageable);

    /**
     * 根据学生id和成绩和章节名称模糊查询获取学习计划列表,最近创建的排上面(成绩为-1d,则为计划列表)
     *
     * @param currentScore
     *            the current score
     * @param bookContentName
     *            the book content name
     * @param pageable
     *            the pageable
     * @return the page< yxy huixue plan>
     */
    Page<YxyHuixuePlan> findByStudentIdAndCurrentScoreAndBookContentNameLike(String studentId, Double currentScore,
            String bookContentName, Pageable pageable);

    /**
     * 根据学生id和学习状态和学科id查询学习计划
     *
     * @param studentId
     *            the student id
     * @param currentScore
     *            the current score
     * @param bookContentName
     *            the book content name
     * @param pageable
     *            the pageable
     * @return the page< yxy huixue plan>
     */
    List<YxyHuixuePlan> findByStudentIdAndStatusAndSubject(String studentId, Integer status, String subject);

    List<YxyHuixuePlan> findByStudentIdAndStatus(String studentId, int i);

    List<YxyHuixuePlan> findByStudentIdAndStatusAndCurrentScoreGreaterThanOrderByEndDateDesc(String studentId,
            Integer status, Integer currentScore);

    Page<YxyHuixuePlan> findByStudentIdAndStatusAndCurrentScoreGreaterThanOrderByEndDateDesc(String studentId, int i,
            int j, Pageable pageable);

    Page<YxyHuixuePlan> findByStudentIdAndStatusAndCurrentScoreGreaterThanOrderByLastModifiedDateDesc(String studentId,
            int i, int j, Pageable pageable);

    Integer countByBookContentIdAndStatusAndCurrentScoreGreaterThan(String bookContentId, int i, int j);

    Integer countByBookContentIdAndStatusAndCurrentScoreLessThan(String bookContentId, int i, Double score);
}
